const path=require('path')

const webpack = require('webpack')

//读取环境类型:production,developer
const ENV = process.env.NODE_ENV;

const ASSET_PATH = "/";

module.exports = {
    //告诉webpack从哪里开始读取代码
    context:path.resolve(__dirname,"src"),
    entry:{
        app:"index.js" //设置app入口节点：context+index.js
    },
    output:{
        //打包后的输出目录
        path:path.resolve(__dirname,"dist"),
        //静态资源路径根目录
        publickPath:ASSET_PATH,
        //打包后的文件格式
        filename:"[name].[hash].js"
    },
    plugins: [
        
        //该插件确保process.env.NODE_ENV会被设置为正确的值
        new webpack.DefinePlugin({
            'process.env.NODE_ENV': JSON.stringify(ENV)
        })
    ]
};
